//
//  BwhcViewCell.m
//  YiqiMobile
//
//  Created by henry on 13-4-6.
//  Copyright (c) 2013年 henry. All rights reserved.
//

#import "BwhcViewCell.h"
#import "Config.h"
#import "Utility.h"

@implementation BwhcViewCell

- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        // Initialization code
        self.selectionStyle=UITableViewCellSelectionStyleNone;
        self.backgroundColor = [UIColor clearColor];
        UIImageView *bg=[[UIImageView alloc] initWithFrame:self.frame];
        bg.image=[UIImage imageNamed:@"homepageCellbg1.png"];
        self.backgroundView=bg;
        
        self.startImageView=[[UIImageView alloc] initWithFrame:CGRectMake(8, 24, 6, 6)];
        self.startImageView.image=[Utility imageNamed:@"homepagecellstar.png"];
        [self addSubview:self.startImageView];
        
        self.content=[self detailTextLabel:CGRectMake(20, 15, 240, 20) andFontSize:15.0f];
        self.content.textColor=UIColorFromRGB(0x555555);
        self.content.text=@"最轻松一天永远是昨天";
        [self addSubview:self.content];
        
        UIImageView *arrowImageView=[[UIImageView alloc] initWithFrame:CGRectMake(280, 18, 19, 19)];
        arrowImageView.image=[Utility imageNamed:@"homepageCellarrow.png"];
        [self addSubview:arrowImageView];
        
        //详细内容
        
        self.detailTitle1=[self detailTextLabel:CGRectMake(5, 38, 80, 14) andFontSize:9.0f];
        self.detailTitle1.textColor=UIColorFromRGB(0x666666);
        self.detailTitle1.text=@"来自圈子:饭醉集团";
        [self addSubview:self.detailTitle1];
        
        self.detailTitle2=[self detailTextLabel:CGRectMake(85, 38, 55, 14) andFontSize:9.0f];
        self.detailTitle2.textColor=UIColorFromRGB(0x666666);
        self.detailTitle2.text=@"阅读:11123";
        [self addSubview:self.detailTitle2];
        
        self.detailTitle3=[self detailTextLabel:CGRectMake(140, 38, 50, 14) andFontSize:9.0f];
        self.detailTitle3.textColor=UIColorFromRGB(0x666666);
        self.detailTitle3.text=@"评论:2863";
        [self addSubview:self.detailTitle3];
        
        self.detailTitle4=[self detailTextLabel:CGRectMake(190, 38, 50, 14) andFontSize:9.0f];
        self.detailTitle4.textColor=UIColorFromRGB(0x666666);
        self.detailTitle4.text=@"收藏:33";
        [self addSubview:self.detailTitle4];
        
        self.detailTitle5=[self detailTextLabel:CGRectMake(240, 38, 80, 14) andFontSize:9.0f];
        self.detailTitle5.textColor=UIColorFromRGB(0x666666);
        self.detailTitle5.text=@"发布:2013/3/23";
        [self addSubview:self.detailTitle5];
    }
    return self;
}

-(UILabel *) detailTextLabel:(CGRect) rect  andFontSize:(float) fontsize{
    UIFont *font=[UIFont fontWithName:FONT_FAMILY size:fontsize];
    UILabel *labeltemp=[[UILabel alloc] initWithFrame:rect];
    labeltemp.font=font;
    labeltemp.backgroundColor=[UIColor clearColor];
    return labeltemp;
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated
{
    [super setSelected:selected animated:animated];
    if (selected) {
        UIImageView *bg=[[UIImageView alloc] initWithFrame:self.frame];
        bg.image=[UIImage imageNamed:@"homepageCellbg2.png"];
        self.backgroundView=bg;
    }else{
        
        UIImageView *bg=[[UIImageView alloc] initWithFrame:self.frame];
        bg.image=[UIImage imageNamed:@"homepageCellbg1.png"];
        self.backgroundView=bg;
    }
    
    // Configure the view for the selected state
}
@end
